//
//  B_UserOrderManagerVC.m
//  DreamOf
//
//  Created by 薛小刚 on 2018/8/29.
//  Copyright © 2018年 薛小刚. All rights reserved.
//

#import "B_UserOrderManagerVC.h"
#import "B_SelectNavView.h"
#import "MainSelectTypeViewController.h"
#import "B_UserSalesReturnVC.h"
#import "B_UserOrderDoneVC.h"
#import "B_UserForPaymentOrderVC.h"
#import "B_UserPaymentDoneVC.h"
#import "B_GoodsListVC.h"
#import "B_MineMemberVC.h"

@interface B_UserOrderManagerVC ()
@property (nonatomic, strong) MainSelectTypeViewController * mainPage;

@property (nonatomic, strong) B_GoodsListVC * goodsList;

@property (nonatomic, strong) B_MineMemberVC * mineMember;

@end

@implementation B_UserOrderManagerVC

- (void)viewDidLoad {
    [super viewDidLoad];
    WeakSelf(weSelf, self);
    self.goodsList.view.hidden = NO;
    B_SelectNavView * navCen = [[B_SelectNavView alloc] initWithFrame:CGRectMake(0, 0, 150, 44)];
    self.navigationItem.titleView = navCen;
    navCen.titleArray = @[@"商品", @"订单", @"会员"];
    
    navCen.tapActionWithIndex = ^(NSInteger index) {
        //TODO:执行切换活动和话题
        dispatch_async(dispatch_get_main_queue(), ^{
            if (index == 0) {
                
                weSelf.mainPage.view.hidden = YES;
                weSelf.goodsList.view.hidden = NO;
                weSelf.mineMember.view.hidden = YES;
            } else if (index == 1) {
                weSelf.mainPage.view.hidden = NO;
                weSelf.goodsList.view.hidden = YES;
                weSelf.mineMember.view.hidden = YES;
            } else if (index == 2) {
                weSelf.mainPage.view.hidden = YES;
                weSelf.goodsList.view.hidden = YES;
                weSelf.mineMember.view.hidden = NO;
            }
        });
        
    };
}

- (MainSelectTypeViewController *)mainPage {
    if (!_mainPage) {
        _mainPage = [[MainSelectTypeViewController alloc] initWithFrame:CGRectMake(0, 5, SCREEN_WIDTH, SCREEN_HEIGHT_X - 64 - 5) titleArray:nil];
        _mainPage.type = B_SelectTypeCircularBead;
        [self.view addSubview:_mainPage.view];
         [self addChildViewController:_mainPage];
        _mainPage.titleArray = @[@"待发货", @"待收货", @"已完成"];
//        B_UserSalesReturnVC * all = [[B_UserSalesReturnVC alloc] init];
        B_UserForPaymentOrderVC * forPayment = [[B_UserForPaymentOrderVC alloc] init];
        B_UserPaymentDoneVC * paymentDone = [[B_UserPaymentDoneVC alloc] init];
        B_UserOrderDoneVC * done = [[B_UserOrderDoneVC alloc] init];
        _mainPage.viewControllers = @[forPayment, paymentDone, done];
        _mainPage.block = ^(NSInteger index) {
            
        };
    }
    return _mainPage;
}

- (B_GoodsListVC *)goodsList {
    if (!_goodsList) {
        _goodsList = [[B_GoodsListVC alloc] init];
        [self addChildViewController:_goodsList];
        [self.view addSubview:_goodsList.view];
        [_goodsList.view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.view);
        }];
    }
    return _goodsList;
}

- (B_MineMemberVC *)mineMember {
    if (!_mineMember) {
        _mineMember = [[B_MineMemberVC alloc] init];
        [self addChildViewController:_mineMember];
        [self.view addSubview:_mineMember.view];
        [_mineMember.view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.view);
        }];
    }
    return _mineMember;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
